#include<iostream>
#include<vector>

using namespace std;

int jump(vector<int>& nums) {
    int length = nums.size();

    vector<int>stepNumber(length, -1);
    stepNumber[0] = 0;
    if (length == 1)
    {
        return 0;
    }
    int step = 0;

    for (int i = 0; i < length; i++)
    {
        step = nums[i];
        while (step > 0)
        {
            if (step + i >= length-1)
            {
                return stepNumber[i] + 1;
            }
            else
            {
                if (stepNumber[step + i] == -1)
                {
                    stepNumber[step + i] = stepNumber[i] + 1;
                }
            }
            step--;
        }
    }
    return stepNumber[length - 1];
}

int main()
{
    vector<int>nums = {0};
    jump(nums);
}